package cn.wmw.xyy.service.impl;

import cn.wmw.xyy.service.ITokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

@Service
public class TokenServiceImpl implements ITokenService {

    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    @Override
    public String getToken(Long courseId) {
       Long loginId = 7L;
       String key = loginId + ":" + courseId;
       String value = UUID.randomUUID().toString();
       redisTemplate.opsForValue().set(key,value,30*60*1000, TimeUnit.MILLISECONDS);
        return value;
    }
}
